package com.day0929.print;
//打印机
public class Printer {
    private Parper parper;//纸张
    private InkBox inkBox;//墨盒

    public Printer(Parper parper, InkBox inkBox) {
        this.parper = parper;
        this.inkBox = inkBox;
    }

    public void print(String content){
        for (int i = 0; i < content.length(); i++) {
            char cha = content.charAt(i);
            if (i != 0 && i % this.parper.getSize() == 0){
                System.out.println();
            }
            this.inkBox.getColor().print(cha);
            try {
                Thread.sleep(300);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }
}
